<?php
namespace app\index\controller;
use catetree\Catetree;
class Article extends Base
{
    public function index($id)
    {
        $TpCate=model('TpCate');
        
        //左侧普通分类
        if(cache('ComCateRes')){
            $ComCateRes=cache('ComCateRes');
        }else{
            $ComCateRes=$TpCate->getComCates();
             if($this->configs['cache_button']=='是'){
                cache('ComCateRes', $ComCateRes,$this->configs['cache_time']);//设置缓存

            }

        }
        	

        //当前文章内容
        $artName=$id.'_arts';

        if(cache($artName)){
            $arts=cache($artName);
        }else{
            $arts=model('TpArticle')->getArts($id);
            if($this->configs['cache_button']=='是'){
                cache($artName,$arts,$this->configs['cache_time']);//设置缓存

            }

        }
        // cache(NULL);
    	

        //面包屑导航
        if(cache('position')){
            $position=cache('position');
        }else{
            $position=$TpCate->position($arts['cate_id']);
            if($this->configs['cache_button']=='是'){
                cache('position', $position,$this->configs['cache_time']);//设置缓存

            }

        }
    	
    	$this->assign(
    	 	[
    	 	'ComCateRes'=>$ComCateRes,
    	 	'arts'=>$arts, 
            'position'=>$position
 
    	 	]
    	);
        return view('article');
    }
}
